<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:awc="clr-namespace:Assergs.Windows.Controls"
    xmlns:aw="clr-namespace:Assergs.Windows"
	>

    <LinearGradientBrush x:Key="ProgressBarTopHighlight" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="#80FFFFFF" Offset="0.05"/>
        <GradientStop Color="#00FFFFFF" Offset="0.25"/>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="ProgressBarGlassyHighlight" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="#50FFFFFF" Offset="0.5385"/>
        <GradientStop Color="#00FFFFFF" Offset="0.5385"/>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="ProgressBarIndicatorGlassyHighlight" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="#90FFFFFF" Offset="0.5385"/>
        <GradientStop Color="#00FFFFFF" Offset="0.5385"/>
    </LinearGradientBrush>

    <RadialGradientBrush x:Key="ProgressBarIndicatorLightingEffectLeft" RadiusX="1" RadiusY="1" RelativeTransform="1,0,0,1,0.5,0.5">
        <GradientStop Color="#60FFFFC4" Offset="0"/>
        <GradientStop Color="#00FFFFC4" Offset="1"/>
    </RadialGradientBrush>

    <LinearGradientBrush x:Key="ProgressBarIndicatorLightingEffect" StartPoint="0,1" EndPoint="0,0">
        <GradientStop Color="#60FFFFC4" Offset="0"/>
        <GradientStop Color="#00FFFFC4" Offset="1"/>
    </LinearGradientBrush>

    <RadialGradientBrush x:Key="ProgressBarIndicatorLightingEffectRight" RadiusX="1" RadiusY="1" RelativeTransform="1,0,0,1,-0.5,0.5">
        <GradientStop Color="#60FFFFC4" Offset="0"/>
        <GradientStop Color="#00FFFFC4" Offset="1"/>
    </RadialGradientBrush>

    <LinearGradientBrush x:Key="ProgressBarIndicatorDarkEdgeLeft" StartPoint="0,0" EndPoint="1,0">
        <GradientStop Color="#0C000000" Offset="0"/>
        <GradientStop Color="#20000000" Offset="0.3"/>
        <GradientStop Color="#00000000" Offset="1"/>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="ProgressBarIndicatorDarkEdgeRight" StartPoint="0,0" EndPoint="1,0">
        <GradientStop Color="#00000000" Offset="0"/>
        <GradientStop Color="#20000000" Offset="0.7"/>
        <GradientStop Color="#0C000000" Offset="1"/>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="ProgressBarIndicatorAnimatedFill" MappingMode="Absolute" StartPoint="-100,0" EndPoint="0,0">
        <GradientStop Color="#00000000" Offset="0"/>
        <GradientStop Color="#FF000000" Offset="0.4"/>
        <GradientStop Color="#FF000000" Offset="0.6"/>
        <GradientStop Color="#00000000" Offset="1"/>
    </LinearGradientBrush>

    <SolidColorBrush x:Key="ForegroundBrush" Color="{x:Static aw:ProgressBarPallet.Foreground}"/>
    <SolidColorBrush x:Key="BackgroundBrush" Color="{x:Static aw:ProgressBarPallet.Background}"/>
    <SolidColorBrush x:Key="NormalBorderBrush" Color="{x:Static aw:ProgressBarPallet.NormalBorder}"/>
    <SolidColorBrush x:Key="AnimationHighLightBrush" Color="{x:Static aw:ProgressBarPallet.AnimationHighLight}"/>
       
    <Style x:Key="{x:Type ProgressBar}" TargetType="{x:Type ProgressBar}">
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="Background" Value="{StaticResource BackgroundBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource NormalBorderBrush}"/>
        <!--<Setter Property="BorderBrush" Value="{StaticResource ProgressBarBorderBrush}"/>-->
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ProgressBar}">
                    <Grid Name="Background"
                          SnapsToDevicePixels="true">
                        <Rectangle Fill="{TemplateBinding Background}"
                                   RadiusX="2"
                                   RadiusY="2"/>
                        <Border Background="{StaticResource ProgressBarGlassyHighlight}"
                                Margin="1"
                                CornerRadius="2"/>
                        <Border BorderBrush="#80FFFFFF"
                                Background="{StaticResource ProgressBarTopHighlight}"
                                BorderThickness="1,0,1,1"
                                Margin="1"/>
                        <Rectangle Name="PART_Track"
                                   Margin="1"/>

                        <Decorator x:Name="PART_Indicator"
                                   HorizontalAlignment="Left"
                                   Margin="1">
                            <Grid Name="Foreground">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition MaxWidth="15"/>
                                    <ColumnDefinition Width="0.1*"/>
                                    <ColumnDefinition MaxWidth="15"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                                <Rectangle x:Name="Indicator"
                                           Grid.RowSpan="2"
                                           Grid.ColumnSpan="3"
                                           Fill="{TemplateBinding Foreground}"/>
                                <Rectangle x:Name="Animation"
                                           Grid.RowSpan="2"
                                           Grid.ColumnSpan="3"
                                           Fill="{TemplateBinding Foreground}">
                                    <Rectangle.OpacityMask>
                                        <MultiBinding>
                                            <MultiBinding.Converter>
                                                <aw:ProgressBarHighlightConverter/>
                                            </MultiBinding.Converter>
                                            <Binding Source="{StaticResource ProgressBarIndicatorAnimatedFill}"/>
                                            <Binding Path="ActualWidth"
                                                     ElementName="Background"/>
                                            <Binding Path="ActualHeight"
                                                     ElementName="Background"/>
                                        </MultiBinding>
                                    </Rectangle.OpacityMask>
                                </Rectangle>
                                <Rectangle x:Name="LeftDark"
                                           Grid.RowSpan="2"
                                           Fill="{StaticResource ProgressBarIndicatorDarkEdgeLeft}"
                                           RadiusX="1"
                                           RadiusY="1"
                                           Margin="1,1,0,1"/>
                                <Rectangle x:Name="RightDark"
                                           Grid.RowSpan="2"
                                           Grid.Column="2"
                                           RadiusX="1"
                                           RadiusY="1"
                                           Fill="{StaticResource ProgressBarIndicatorDarkEdgeRight}"
                                           Margin="0,1,1,1"/>
                                <Rectangle x:Name="LeftLight"
                                           Grid.Column="0"
                                           Grid.Row="2"
                                           Fill="{StaticResource ProgressBarIndicatorLightingEffectLeft}"/>
                                <Rectangle x:Name="CenterLight"
                                           Grid.Column="1"
                                           Grid.Row="2"
                                           Fill="{StaticResource ProgressBarIndicatorLightingEffect}"/>
                                <Rectangle x:Name="RightLight"
                                           Grid.Column="2"
                                           Grid.Row="2"
                                           Fill="{StaticResource ProgressBarIndicatorLightingEffectRight}"/>
                                <Border x:Name="Highlight1"
                                        Grid.RowSpan="2"
                                        Grid.ColumnSpan="3"
                                        Background="{StaticResource ProgressBarIndicatorGlassyHighlight}"/>
                                <Border x:Name="Highlight2"
                                        Grid.RowSpan="2"
                                        Grid.ColumnSpan="3"
                                        Background="{StaticResource ProgressBarTopHighlight}"/>
                            </Grid>
                        </Decorator>

                        <Border BorderThickness="{TemplateBinding BorderThickness}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                CornerRadius="2"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Orientation"
                                 Value="Vertical">
                            <Setter TargetName="Background"
                                    Property="LayoutTransform">
                                <Setter.Value>
                                    <RotateTransform Angle="-90"/>
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="PART_Track"
                                    Property="LayoutTransform">
                                <Setter.Value>
                                    <RotateTransform Angle="90"/>
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="PART_Indicator"
                                    Property="LayoutTransform">
                                <Setter.Value>
                                    <RotateTransform Angle="90"/>
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="Foreground"
                                    Property="LayoutTransform">
                                <Setter.Value>
                                    <RotateTransform Angle="-90"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>

                        <Trigger Property="IsIndeterminate"
                                 Value="true">
                            <Setter TargetName="LeftDark"
                                    Property="Visibility"
                                    Value="Collapsed"/>
                            <Setter TargetName="RightDark"
                                    Property="Visibility"
                                    Value="Collapsed"/>
                            <Setter TargetName="LeftLight"
                                    Property="Visibility"
                                    Value="Collapsed"/>
                            <Setter TargetName="CenterLight"
                                    Property="Visibility"
                                    Value="Collapsed"/>
                            <Setter TargetName="RightLight"
                                    Property="Visibility"
                                    Value="Collapsed"/>
                            <Setter TargetName="Indicator"
                                    Property="Visibility"
                                    Value="Collapsed"/>
                        </Trigger>
                        <Trigger Property="IsIndeterminate"
                                 Value="false">
                            <Setter TargetName="Animation"
                                    Property="Fill"
                                    Value="{StaticResource AnimationHighLightBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>